<template>
  <div>
    <el-card>
      <div slot="header" style="margin-left: 6%">注册用户列表</div>
      <el-table
        :data="tableData"
        style="width: 88%; margin: 0 auto"
        max-height="1000"
        align="center"
        border
      >
        <el-table-column fixed type="index" width="50" label="序号">
        </el-table-column>
        <el-table-column
          width="150"
          label="用户名"
          prop="username"
          align="center"
          class="names"
        >
        </el-table-column>

        <el-table-column
          prop="province"
          label="头像"
          width="150"
          align="center"
        >
          <template slot-scope="scope">
            <img
              style="width: 100px; height: 100px; border-radius: 50px"
              :src="scope.row.icon"
              alt=""
            />
          </template>
        </el-table-column>
        <el-table-column
          width="200"
          label="昵称"
          prop="nickname"
          align="center"
        >
        </el-table-column>
        <el-table-column
          width="150"
          label="真实姓名"
          prop="realname"
          align="center"
        >
        </el-table-column>
        <el-table-column
          width="150"
          label="性别"
          prop="realname"
          align="center"
        >
        </el-table-column>
        <el-table-column width="150" label="电话" prop="phone" align="center">
        </el-table-column>
        <el-table-column
          width="150"
          label="邮箱"
          prop="realname"
          align="center"
        >
        </el-table-column>
        <el-table-column
          width="150"
          label="生日"
          prop="realname"
          align="center"
        >
        </el-table-column>
        <el-table-column
          width="180"
          label="注册时间时间"
          prop="createTime"
          align="center"
        >
        </el-table-column>
      </el-table>
    </el-card>

    <el-pagination
      :current-page="page.currentPage"
      :page-sizes="page.pageSizes"
      :page-size="page.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    >
    </el-pagination>
  </div>
</template>

<script>
import registeredUser from '@/api/registeredUser.js'
// import product from '@/api/product.js'
import mixin from '@/mixins'
export default {
  mixins: [mixin],

  data() {
    return {
      tableData: [],
      value: '',
    }
  },
  created() {},
  mounted() {
    this.findMembersByPageApi()
  },
  methods: {
    // findBrandByPageApi() {
    //   product.findBrandByPageApi(10, 1).then(res => {
    //     console.log(res)
    //   })
    // },
    findMembersByPageApi() {
      setTimeout(() => {
        registeredUser
          .findMembersByPageApi(
            this.page.currentPage,
            this.page.pageSize,
            this.from,

            {
              showStatus: 1,
            }
          )
          .then(res => {
            if (res.success) {
              this.tableData = res.data.rows
              this.page.total = res.data.total
            } else {
              this.$message.error('请求失败')
            }

            console.log(this.tableData, 'this.tableData')
          })
      })
    },
    // newest(row) {
    //   console.log(row.showStatus, 'row')
    //   // var ermpStatus = row.showStatus === 1 ? 0 : 1 //如果失败了  0就是1  1就是0
    //   product
    //     .switchShowStatusApi({
    //       id: row.id,
    //       status: row.showStatus,
    //     })
    //     .then(res => {
    //       console.log(res, 'res')
    //       if (res.success == true) {
    //         this.$message.success('修改状态成功')
    //       } else {
    //         this.$message.error('修改状态失败，请联系管理员')
    //         // row.showStatus = ermpStatus
    //       }
    //     })
    // },
    //删除商品
    // deleteRow(row) {
    //   console.log(row, '删除')
    //   this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: 'warning',
    //   }).then(() => {
    //     product.delBrandApi(row).then(res => {
    //       if (res.success) {
    //         this.$message.success('删除成功')
    //         this.findBrandByPageApi()
    //       } else {
    //         this.$message.error(res.message)
    //       }
    //     })
    //   })
    // },
    //每页多少条 改变时触发事件
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.page.pageSize = val
      this.findMembersByPageApi()
    },
    //修改页触发的事件
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.page.currentPage = val
      this.findMembersByPageApi()
    },
  },
}
</script>

<style>
</style>